home *** CD-ROM | disk | FTP | other *** search
/ Loadstar Extras 3 / Ex3side2.d64 / loader src.sda / READER.SRC < prev    next >
Text File  |  2022-08-28  |  17KB  |  1,814 lines

  1.  
  2.  
  3. ;**** reader.src
  4.  
  5.  
  6. ;sys,addr y,x1,x2,number items,text,highlight,esc
  7.  
  8. ;***sys addr,x,to x,y,to y,s-code,color
  9.  
  10. box'entry lda #5
  11. sta parm'count
  12. box'ii lda #0
  13. sta temp
  14. - jsr get'number
  15. tya
  16. ldy temp
  17. sta box'parameters,y
  18. inc temp
  19. cpy parm'count
  20. bne -
  21.  
  22. fill'box jsr linx
  23. lda 214
  24. pha
  25. lda 211
  26. pha
  27. box'start ldx box'parameters+2
  28. ldy #0
  29. clc
  30. jsr $fff0
  31. jsr old'rom'patch
  32. dec box'parameters
  33. ;inc box'parameters+3
  34.  
  35. - ldy box'parameters+1
  36. - lda box'parameters+4
  37. cmp #255
  38. beq +
  39. sta (209),y
  40. + lda box'parameters+5
  41. store'color sta (243),y
  42. dey
  43. cpy box'parameters
  44. bne -
  45. lda 214
  46. cmp box'parameters+3
  47. beq +
  48.  
  49. lda #40
  50. clc
  51. adc 209
  52. sta 209
  53. lda #0
  54. adc 210
  55. sta 210
  56. lda #40
  57. clc
  58. adc 243
  59. sta 243
  60. lda #0
  61. adc 244
  62. sta 244
  63. inc 214
  64. jmp --
  65.  
  66. + lda #home
  67. jsr $ffd2
  68. pla
  69. sta 211
  70. pla
  71. sta 214
  72. jmp 58732
  73.  
  74. linx ldy #24
  75. - lda 217,y
  76. ora #128
  77. sta 217,y
  78. dey
  79. bpl -
  80. rts
  81.  
  82. ;**** get number from BASIC ****
  83.  
  84. get'number jsr $aefd
  85. jsr $ad8a
  86. jmp $b7f7
  87.  
  88. ;***** get string from BASIC ****
  89.  
  90. get'string jsr $aefd
  91. jsr $ad9e
  92. jsr $b6a3
  93.  
  94. ldx $22
  95. ldy $23
  96. rts
  97.  
  98. print'at jsr linx
  99. jsr get'number
  100. sty 211
  101. jsr get'number
  102. sty 214
  103. jsr 58732
  104. jsr get'string
  105. sta temp
  106.  
  107. print'string lda temp
  108. beq +
  109. ldy #0
  110. - lda ($22),y
  111. jsr chrout
  112. iny
  113. cpy temp
  114. bne -
  115. + rts
  116.  
  117. center jsr get'number
  118. tya
  119. tax
  120. ldy #0
  121. clc
  122. jsr plot
  123.  
  124. jsr get'string
  125. mcenter sta temp
  126.  
  127. lsr
  128. sta flag
  129. lda #20
  130. sec
  131. sbc flag
  132. sta 211
  133. jsr 58732
  134. jmp print'string
  135.  
  136. old'rom'patch lda 210
  137. sec
  138. sbc 648
  139. clc
  140. adc #$d8
  141. sta 244
  142. lda 209
  143. sta 243
  144. rts
  145.  
  146. bload jsr get'string
  147. jsr setnam
  148. jsr get'number
  149. tya
  150. tax
  151. lda #2
  152. ldy #0
  153. jsr setlfs
  154. jsr get'number
  155. sty base
  156. sty resume
  157. sta base+1
  158. sta resume+1
  159. lda #1
  160. sta resume'line
  161. lda #0
  162. sta resume'line+1
  163. ldx $14
  164. ldy $15
  165. lda #0
  166. jsr load
  167. ldy #0
  168. tya
  169. jsr rom'out
  170. sta (174),y
  171. jmp rom'in
  172.  
  173.  
  174. do'box stx 251
  175. sty 252
  176. ldy #5
  177. - lda (251),y
  178. sta box'parameters,y
  179. dey
  180. bpl -
  181. jmp fill'box
  182.  
  183. do'frame stx 251
  184. sty 252
  185. ldy #4
  186. - lda (251),y
  187. sta box'parameters,y
  188. dey
  189. bpl -
  190. jmp frame'up
  191.  
  192. frame'entry lda #4
  193. sta parm'count
  194. frame'ii lda #0
  195. sta temp
  196. - jsr get'number
  197. tya
  198. ldy temp
  199. sta box'parameters,y
  200. inc temp
  201. cpy parm'count
  202. bne -
  203.  
  204. frame'up jsr linx
  205. lda 214
  206. pha
  207. lda 211
  208. pha
  209. frame'start ldx box'parameters+2
  210. ldy #0
  211. clc
  212. jsr plot  
  213. jsr old'rom'patch
  214. ;dec box'parameters
  215.  
  216. ldy box'parameters+1
  217. lda box'parameters+4
  218. pha
  219. and #128
  220. ora #110
  221. sta (209),y
  222. pla 
  223. sta (243),y
  224. dey
  225.  
  226. - lda box'parameters+4
  227. pha
  228. and #128
  229. ora #64
  230. sta (209),y
  231. pla
  232. sta (243),y
  233. dey
  234. cpy box'parameters
  235. bne -
  236.  
  237. lda box'parameters+4
  238. pha
  239. and #128
  240. ora #112
  241. sta (209),y
  242. pla 
  243. sta (243),y
  244.  
  245. - lda #40
  246. clc
  247. adc 209
  248. sta 209
  249. lda #0
  250. adc 210
  251. sta 210
  252. lda #40
  253. clc
  254. adc 243
  255. sta 243
  256. lda #0
  257. adc 244
  258. sta 244
  259. inc 214
  260.  
  261. lda 214
  262. cmp box'parameters+3
  263. bcs do'bottom
  264.  
  265. lda box'parameters+4
  266. pha
  267. and #128
  268. ora #93
  269. ldy box'parameters
  270. sta (209),y
  271. ldy box'parameters+1
  272. sta (209),y
  273. pla
  274. sta (243),y
  275. ldy box'parameters
  276. sta (243),y
  277. jmp -
  278.  
  279. do'bottom ldy box'parameters+1
  280. lda box'parameters+4
  281. pha
  282. and #128
  283. ora #125
  284. sta (209),y
  285. pla 
  286. sta (243),y
  287. dey
  288.  
  289. - lda box'parameters+4
  290. pha
  291. and #128
  292. ora #64
  293. sta (209),y
  294. pla
  295. sta (243),y
  296. dey
  297. cpy box'parameters
  298. bne -
  299.  
  300. lda box'parameters+4
  301. pha
  302. and #128
  303. ora #109
  304. sta (209),y
  305. pla 
  306. sta (243),y
  307.  
  308. pla
  309. sta 211
  310. pla
  311. sta 214
  312. jsr 58732
  313. jmp linx
  314.  
  315. zero'stash ldy #9
  316. - lda 245,y
  317. sta zero'buf,y
  318. dey
  319. bpl -
  320. rts
  321.  
  322. zero'restore ldy #9
  323. - lda zero'buf,y
  324. sta 245,y
  325. dey
  326. bpl -
  327. rts
  328.  
  329. read'existing jsr get'number
  330. sty 174
  331. sta 175
  332. sty base
  333. sta base+1
  334. ldy #0
  335. sty search'length
  336. sei
  337. lda #$74
  338. sta 1
  339. - lda (174),y
  340. bne +
  341. beq ++
  342. + inc 174
  343. bne -
  344. inc 175
  345. jmp -
  346. + lda 174
  347. sta eof
  348. lda 175
  349. sta eof+1
  350. lda #$77
  351. sta 1
  352. cli
  353. jsr get'number
  354. sty resume
  355. sta resume+1
  356. jsr get'number
  357. sty resume'line
  358. sta resume'line+1
  359. jmp resume'entry
  360.  
  361. load'file jsr bload
  362. stx eof
  363. sty eof+1
  364. resume'entry ldy #0
  365. sty setup'flag
  366. sty bottom'flag
  367. lda #147
  368. jsr chrout
  369. lda #32
  370. sta text'color-1
  371. ldy #3
  372. ;sty text'color
  373. ;sty top'frame'color
  374. tya
  375. and #128
  376. ora text'color-1
  377. sta text'color-1
  378. ;ldy #14
  379. ;sty frame'color
  380. ;sty top'box'color
  381. jsr count'lines
  382.  
  383. setup lda #0
  384. sta bottom'flag
  385. ldx <frame'parms
  386. ldy >frame'parms
  387. jsr do'frame
  388.  
  389. ldx <top'frame'parms
  390. ldy >top'frame'parms
  391. jsr do'frame
  392.  
  393. lda top'box'color
  394. sta 646
  395. and #128
  396. sta 199
  397. bit setup'flag
  398. bmi +
  399. lda top'box'parms+4
  400. ora 199
  401. sta top'box'parms+4
  402. ldx <top'box'parms
  403. ldy >top'box'parms
  404. jsr do'box
  405. ldx #2
  406. ldy #0
  407. clc
  408. jsr plot
  409. ;jsr get'string
  410. ;jsr mcenter
  411. ;jsr get'number
  412. ;sty chapter
  413. jsr find'header
  414. jsr print'header
  415. + lda #255
  416. sta setup'flag
  417. ldx <text'parms
  418. ldy >text'parms
  419. jsr do'box
  420. ldx frame'parms+3
  421. inx
  422. jsr 59903
  423. ldx frame'parms+3
  424. inx
  425. ldy #5
  426. clc
  427. jsr plot
  428. lda frame'parms+4
  429. sta 646
  430.  
  431. ;lda <line'text
  432. ;ldy >line'text
  433. ;jsr strout
  434. ldx #18
  435. stx 211
  436. jsr 58732
  437.  
  438. lda text'parms+5
  439. sta 646
  440.  
  441. ; ldx line'count
  442. ;lda line'count+1
  443. ;jsr print'number
  444.  
  445. lda frame'parms+4
  446. sta 646
  447. inc 214
  448. lda #1
  449. sta 211
  450. jsr 58732
  451. lda <lil'menu
  452. ldy >lil'menu
  453. jsr strout
  454.  
  455. inc 214
  456. lda #0
  457. sta 211
  458. jsr 58732
  459. lda <lil'too
  460. ldy >lil'too
  461. jsr strout
  462. ldx 214
  463. dex
  464. dex
  465. ldy #1
  466. clc
  467. jsr plot
  468. jsr old'rom'patch
  469.  
  470. ldy #120
  471. - lda (209),y
  472. bpl +
  473. and #127
  474. sta (209),y
  475. lda text'parms+5
  476. sta (243),y
  477. + dey
  478. bpl -
  479.  
  480. lda base
  481. sta 251
  482. lda base+1
  483. sta 252
  484. lda #0
  485. sta text'loc
  486. sta text'loc+1
  487. lda #1
  488. sta cur'line
  489. lda #0
  490. sta cur'line+1
  491. lda text'color
  492. sta 646
  493. jsr page
  494. jsr print'line'no
  495. lda text'back
  496. sta 53280
  497. sta 53281
  498.  
  499. get'text'key jsr getin
  500. beq get'text'key
  501. cmp #17
  502. bne +
  503. jsr text'down
  504. jsr print'line'no
  505. jmp get'text'key
  506. + cmp #145
  507. bne +
  508. jsr text'up
  509. jsr print'line'no
  510. jmp get'text'key
  511. + cmp #19
  512. bne +
  513. lda base
  514. sta resume
  515. lda base+1
  516. sta resume+1
  517. lda #1
  518. sta resume'line
  519. lda #0
  520. sta resume'line+1
  521. jmp setup
  522.  
  523. + cmp #crsr'right
  524. bne +
  525. jmp page'down
  526.  
  527. + cmp "_"
  528. bne +
  529. lda "q"
  530.  
  531. + cmp #13
  532. bne +
  533. lda "q"
  534.  
  535. + cmp #crsr'left
  536. bne +
  537. jmp page'up
  538.  
  539. + cmp #147
  540. bne +
  541. jsr move'bottom
  542. jsr print'line'no
  543. jmp get'text'key
  544.  
  545. + cmp "b"
  546. bne +
  547. inc text'back
  548. lda text'back
  549. sta 53280
  550. sta 53281
  551. jmp get'text'key
  552.  
  553.  
  554. + cmp "s"
  555. bne +
  556. jsr save'text
  557. jsr print'header
  558. lda text'color
  559. sta 646
  560. lda #0
  561. sta 199
  562.  
  563. jmp get'text'key
  564.  
  565.  
  566. + cmp "q"
  567. bne +
  568.  
  569. rts
  570.  
  571. + cmp "c"
  572. bne +
  573. jsr color'cycle
  574. jmp get'text'key
  575.  
  576. + cmp #1
  577. bne +
  578. rts
  579.  
  580. + cmp #16
  581. bne +
  582. jsr print'text
  583. jmp setup
  584.  
  585. + cmp "p"
  586. beq +
  587. jmp get'text'key
  588. + jsr print'text
  589. jmp setup
  590.  
  591. text'down lda bottom'flag
  592. bne +++
  593. + jsr zero'stash
  594. ldx <text'parms
  595. ldy >text'parms
  596. jsr do'scroll'down
  597. inc cur'line
  598. bne +
  599. inc cur'line+1
  600.  
  601. + jmp zero'restore
  602. + rts
  603.  
  604. do'scroll'down stx 251
  605. sty 252
  606. ldy #3
  607. - lda (251),y
  608. sta startingx,y
  609. dey
  610. bpl -
  611. jsr scroll'up
  612.  
  613. lda text'color-1
  614. sta char
  615. lda text'color
  616. sta color
  617. jsr clear'ii
  618.  
  619. print'new'bottom'line lda text'loc
  620. sta 251
  621. lda text'loc+1
  622. sta 252
  623. jsr page'loop
  624. jsr rom'out
  625. ldy #0
  626. lda box'top
  627. sta 251
  628. lda box'top+1
  629. sta 252
  630. lda text'color
  631. and #128
  632. sta 199
  633. - lda (251),y
  634. cmp #13
  635. beq nbo
  636. inc 251
  637. bne +
  638. inc 252
  639. + jmp -
  640. nbo lda 251
  641. sta box'top
  642. lda 252
  643. sta box'top+1
  644. jmp rom'in
  645.  
  646.  
  647. page lda text'color
  648. sta 646
  649. and #128
  650. sta 199
  651.  
  652. ldy text'parms
  653. ldx text'parms+2
  654. clc
  655. jsr plot
  656.  
  657. page'loop ldy #0
  658. - jsr rom'out
  659. lda (251),y
  660. jsr bump'251
  661. cmp #0
  662. beq hit'bottom
  663. jsr rom'in
  664. jsr chrout
  665. lda 211
  666. bne -
  667.  
  668. lda text'color
  669. and #128
  670. sta 199
  671. lda #29
  672. jsr chrout
  673. lda 214
  674. cmp frame'parms+3
  675. bcs +
  676. jmp -
  677. / lda 251
  678. sta text'loc
  679. lda 252
  680. sta text'loc+1
  681. rts
  682.  
  683. hit'bottom jsr rom'in
  684. lda #1
  685. sta bottom'flag
  686. jmp -
  687.  
  688. page'down lda #14
  689. sta wordbuf
  690. - lda #0
  691. sta 199
  692. jsr text'down
  693. lda bottom'flag
  694. bne +
  695. dec wordbuf
  696. bpl -
  697. + jsr print'line'no
  698. jmp get'text'key
  699.  
  700. page'up lda #14
  701. sta wordbuf
  702. - jsr text'up
  703. lda cur'line+1
  704. bne +
  705. lda cur'line
  706. cmp #1
  707. beq ++
  708. + dec wordbuf
  709. bpl -
  710. + jsr print'line'no
  711. jmp get'text'key
  712.  
  713. rom'out pha
  714. sei
  715. lda #$74
  716. sta 1
  717. pla
  718. rts
  719.  
  720. rom'in pha
  721. lda #$77
  722. sta 1
  723. cli
  724. pla
  725. rts
  726.  
  727. bump'251 inc 251
  728. bne +
  729. inc 252
  730. + rts
  731.  
  732. get'scroll'up jsr get'scroll'parms
  733. jmp scroll'up
  734.  
  735. get'scroll'down jsr get'scroll'parms
  736. jmp scroll'down
  737.  
  738. get'scroll'parms stx 251
  739. sty 252
  740. ldy #3
  741. - lda (251),y
  742. sta startingx,y
  743. dey
  744. bpl -
  745. rts
  746.  
  747. scroll'up ldy startingx
  748. ldx startingy
  749. stx line
  750. clc
  751. jsr plot
  752. jsr old'rom'patch
  753.  
  754. scroll'up'math clc
  755. lda 209
  756. adc <40
  757. sta 251
  758. lda 210
  759. adc >40
  760. sta 252
  761.  
  762. clc
  763. lda 243
  764. adc <40
  765. sta 253
  766. lda 244
  767. adc >40
  768. sta 254
  769.  
  770. ldy startingx
  771.  
  772. - lda (251),y
  773. sta (209),y
  774. lda (253),y
  775. sta (243),y
  776. iny
  777. cpy endingx
  778. beq -
  779. bcc -
  780.  
  781. inc line
  782. lda line
  783. cmp endingy
  784. bcs through'scrolling'up
  785.  
  786. clc
  787. lda 209
  788. adc <40
  789. sta 209
  790. lda 210
  791. adc >40
  792. sta 210
  793.  
  794. clc
  795. lda 243
  796. adc <40
  797. sta 243
  798. lda 244
  799. adc >40
  800. sta 244
  801. jmp scroll'up'math
  802.  
  803. through'scrolling'up ldx endingy
  804. ldy startingx
  805. clc
  806. jsr plot
  807. jmp old'rom'patch
  808.  
  809. scroll'down ldy startingx
  810. ldx endingy
  811. stx line
  812. clc
  813. jsr plot
  814. jsr old'rom'patch
  815.  
  816. scroll'down'math sec
  817. lda 209
  818. sbc <40
  819. sta 251
  820. lda 210
  821. sb